package tinyinventor;

import codeblocks.Block;
import codeblocks.BlockConnector;
import codeblocks.LinkRule;

public class TypeRule implements LinkRule {

	@Override
	public boolean canLink(Block block1, Block block2, BlockConnector socket1, BlockConnector socket2) {

		String block1Type = block1.getProperty("type");
		String block2Type = block2.getProperty("type");
				
		if(block1Type==null) {
			System.err.println("Missing type on " + block1.getGenusName() + " genus");
		}
		
		if(block2Type==null) {
			System.err.println("Missing type on " + block2.getGenusName() + " genus");
		}

		if(block1Type==null || block2Type==null) {
			return false;
		} else {
			return block1Type.equals(block2Type);
		}
		
	}

	@Override
	public boolean isMandatory() {
		return false;
	}

}
